package com.share.tool.devops.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.share.tool.devops.dao.HttpRequestLogMapper;
import com.share.tool.devops.model.po.HttpUrlConfig;
import com.share.tool.devops.model.po.HttpRequestLog;
import com.share.tool.devops.service.HttpRequestLogService;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class HttpRequestLogServiceImpl extends ServiceImpl<HttpRequestLogMapper, HttpRequestLog> implements HttpRequestLogService {

    @Override
    public Integer insertLog(HttpUrlConfig item, int dealStatus, String param) {
        HttpRequestLog record = new HttpRequestLog();
        record.setCreateTime(new Date());
        record.setStatus(dealStatus);
        record.setGCode(item.getGCode());
        record.setInterfaceId(item.getId());
        record.setRequestParam(param);
        int insert = this.baseMapper.insert(record);
        if (insert > 0) {
            return record.getId();
        } else {
            return null;
        }
    }
}
